Excel - Name the workbook as well as name the sheet

Hi Guys,
Newbie here again.
My inherited code is creating an Excel workbook/sheet and the script closes,but
leave the workbook/sheet opne. This is fine I like it doing that.
However, I would like to know how can I for the DXL script to name the workbook
and the sheet as well? I just don't want Book1 and Sheet1.

Thanks.
Jerry
SystemAdmin - Tue Aug 23 11:36:33 EDT 2011

Re: Excel - Name the workbook as well as name the sheet
SystemAdmin - Thu Aug 25 06:23:03 EDT 2011

Hi Jerry,

Try something along these lines

void setSheetNameOLE(OleAutoObj objSheet, string sheetName) {
    checkRes(olePut(objSheet, cPropertyName, sheetName))
}
 
void  saveFileAs(OleAutoObj objWorkbook, string filename) {
    clear(objArgBlock)
    put(objArgBlock, "FileName", filename)
    checkRes(oleMethod(objWorkbook, "SaveAs", objArgBlock))
}

 


Regards, Paul

 

Re: Excel - Name the workbook as well as name the sheet
PatrickGuay - Mon Sep 12 14:23:59 EDT 2011

I found that the following form was more accurate:
void setSheetNameOLE(OleAutoObj objSheet, string sheetName) {
olePut(objSheet, "Name", sheetName)
}

void saveFileAs(OleAutoObj objWorkbook, string filename) {
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objWorkbook, "SaveAs", objArgBlock)
}

Thanks for the help

Re: Excel - Name the workbook as well as name the sheet
SystemAdmin - Mon Sep 19 12:10:13 EDT 2011

PatrickGuay - Mon Sep 12 14:23:59 EDT 2011
I found that the following form was more accurate:
void setSheetNameOLE(OleAutoObj objSheet, string sheetName) {
olePut(objSheet, "Name", sheetName)
}

void saveFileAs(OleAutoObj objWorkbook, string filename) {
clear(objArgBlock)
put(objArgBlock, "FileName", filename)
oleMethod(objWorkbook, "SaveAs", objArgBlock)
}

Thanks for the help

Hi All,
I have not tried either suggestion as of yet.
So, I am not sure how these operate or if they work yet.
I just want something that names the sheet and filename automatically without any intervention.
If these suggestions do that then great. If not then I will need to figure that out.
Thanks.
Jerry